package com.hdl.servlet.admin;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hdl.entity.MallProduct;
import com.hdl.service.MallProductService;
import com.hdl.service.impl.MallProductServiceImpl;

@WebServlet("/admin/mallproduct-update2.let")
public class MallProductUpdate2Servlet extends HttpServlet{
	private MallProductService m = new MallProductServiceImpl();
   @Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	   request.setCharacterEncoding("utf-8");
	   
	   String id = request.getParameter("userid");
	   String name = request.getParameter("name");
	   String type = request.getParameter("type");
	   int typeid=0;
	   if("锅底".equals(type)) {typeid=1;}
	   if("涮菜".equals(type)) {typeid=2;}
	   if("特色蘸料".equals(type)) {typeid=3;}
	   if("小吃甜品".equals(type)) {typeid=4;}
	   if("特色饮品".equals(type)) {typeid=5;}
	   int price = Integer.valueOf(request.getParameter("price"));
	   String path = request.getParameter("path");
	   int score = Integer.valueOf(request.getParameter("score"));
	   String ms = request.getParameter("ms");
	   MallProduct mp = new MallProduct();
	   mp.setMallProductId(id);
	   mp.setMallProductName(name);
	   mp.setMallProductPath(path);
	   mp.setMallProductMs(ms);
	   mp.setMallProductPrice1(price);
	   mp.setMallProductScore(score);
	   mp.setMallTypeId(typeid);
	   
	   System.out.println(mp);
	   
	   m.UpdateProduct(id, mp);
	   
	  response.sendRedirect(request.getContextPath()+"/admin/mall-list.let");
	   
}
   
   @Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
